package com.sky.utils;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class OkHttpUtil {

    private final OkHttpClient client;

    public OkHttpUtil(OkHttpClient client) {
        this.client = client;
    }


    public String doGet(String url) {
        try {
            Response response = client.newCall(new Request.Builder().url(url).get().build()).execute();
            if (response.isSuccessful() && response.body() != null) {
                return response.body().string();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return null;
    }
}
